package com.manage.base.bean;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import com.manage.config.model.Config;

public class CommonResultBean
		implements Serializable {

	private static final long serialVersionUID = 1L;

	private int result_code = Config.SUCCESS;

	private String result_message = Config.SUCCESS_MSG;

	private Map<String, Object> result_map = new HashMap<String, Object>();

	public int getResult_code() {
		return result_code;
	}

	public void setResult_code(int result_code) {
		this.result_code = result_code;
	}

	public String getResult_message() {
		return result_message;
	}

	public void setResult_message(String result_message) {
		this.result_message = result_message;
	}

	public Map<String, Object> getResult_map() {
		return result_map;
	}

	public void setResult_map(Map<String, Object> result_map) {
		this.result_map = result_map;
	}

	public void setError() {
		setResult_code(Config.FAILE);
		setResult_message(Config.ERROR_MSG);
	}

	public CommonResultBean setErrorMsg(String messge) {
		setResult_code(Config.FAILE);
		setResult_message(messge);
		return this;
	}

	public void put(String key, Object bean) {
		if (result_map == null) {
			setResult_map(new HashMap<String, Object>());
		}
		result_map.put(key, bean);
	}

	public static CommonResultBean errorBean() {
		CommonResultBean crb = new CommonResultBean();
		crb.setError();
		return crb;
	}

	public static CommonResultBean succBean() {
		CommonResultBean crb = new CommonResultBean();
		return crb;
	}

	public static CommonResultBean errorBean(String error) {
		CommonResultBean crb = new CommonResultBean();
		crb.setErrorMsg(error);
		return crb;
	}
}
